<script setup>
import {
    Edit,
    Delete
} from '@element-plus/icons-vue'

import { ref } from 'vue'




const day = ref([])

const pageTypes = ref([
  {
    "id": 1,
    "contentValue": "主页",
  },
  {
    "id": 2,
    "contentValue": "教研页",
  },
  {
    "id": 3,
    "contentValue": "兴趣圈页",
  }
  ,
  {
    "id": 4,
    "contentValue": "会员页",
  }
  ,
  {
    "id": 5,
    "contentValue": "个人中心页",
  },
  {
    "id": 0,
    "contentValue": "其它页",
  }
])

const pageType = ref('')

//文章列表数据模型
const historyData = ref([

])


//分页条数据模型
const pageNum = ref(1)//当前页
const total = ref(20)//总条数
const pageSize = ref(15)//每页条数

//当每页条数发生了变化，调用此函数
const onSizeChange = (size) => {
    pageSize.value = size
     historyDataList()
}
//当前页码发生变化，调用此函数
const onCurrentChange = (num) => {
    pageNum.value = num
    historyDataList()
}






import { Plus } from '@element-plus/icons-vue'
import { QuillEditor } from '@vueup/vue-quill'
import '@vueup/vue-quill/dist/vue-quill.snow.css'
import {userBrowseTimeListService} from "@/api/BrowseLog.js";







const historyDataList = async () => {

    let params = {
        pageNum: pageNum.value,
        pageSize: pageSize.value,
        dayTime: day.value ? day.value : null,
        pageType: pageType.value !=='' ? pageType.value : null,
        account:account.value ?account.value:null
    }
    let result = await userBrowseTimeListService(params);
    //渲染视图
    total.value = result.data.total;
    historyData.value = result.data.records;


}
const orderNo = ref('')

const account = ref('')

const imei = ref('')

const traceKey = ref('')


historyDataList();

</script>
<template>
    <el-card class="page-container">
        <template #header>
            <div class="header">
                <span>用户日志</span>
            </div>
        </template>
        <!-- 搜索表单 -->
        <el-form inline>
          <el-form-item label="时间：">
            <el-date-picker
                v-model="day"
                type="date"
                format="YYYY-MM-DD"
                value-format="YYYY-MM-DD"
            />
          </el-form-item>
            <el-form-item label="账户：">
                <el-input  v-model="account" />
            </el-form-item>
          <el-form-item label="类型：">
            <el-select placeholder="请选择" v-model="pageType">
              <el-option v-for="c in pageTypes" :key="c.id" :label="c.contentValue" :value="c.id">
              </el-option>
            </el-select>
          </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="historyDataList">搜索</el-button>
              <el-button @click="day = ''; account=''">重置</el-button>
            </el-form-item>

        </el-form>
        <!-- 文章列表 -->
        <el-table :data="historyData" border style="width: 100%">
            <el-table-column label="时间" width="200" prop="dayTime"></el-table-column>
            <el-table-column label="用户账户" prop="account"></el-table-column>
            <el-table-column label="浏览的页面类型" prop="pageName"></el-table-column>
          <el-table-column label="浏览时间" prop="time"></el-table-column>
            <template #empty>
                <el-empty description="没有数据" />
            </template>
        </el-table>
        <!-- 分页条 -->
        <el-pagination v-model:current-page="pageNum" v-model:page-size="pageSize" :page-sizes="[3, 5, 10, 15]"
            layout="jumper, total, sizes, prev, pager, next" background :total="total" @size-change="onSizeChange"
            @current-change="onCurrentChange" style="margin-top: 20px; justify-content: flex-end" />




    </el-card>
</template>
<style lang="scss" scoped>
.page-container {
    min-height: 100%;
    box-sizing: border-box;

    .header {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
}


/* 抽屉样式 */
.avatar-uploader {
    :deep() {
        .avatar {
            width: 178px;
            height: 178px;
            display: block;
        }

        .el-upload {
            border: 1px dashed var(--el-border-color);
            border-radius: 6px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
            transition: var(--el-transition-duration-fast);
        }

        .el-upload:hover {
            border-color: var(--el-color-primary);
        }

        .el-icon.avatar-uploader-icon {
            font-size: 28px;
            color: #8c939d;
            width: 178px;
            height: 178px;
            text-align: center;
        }
    }
}

.editor {
    width: 100%;

    :deep(.ql-editor) {
        min-height: 200px;
    }
}
</style>